﻿@model  Model.SysMenuInfo
@{
    ViewBag.Title = "系统日志管理";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <script src="/Res/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script> 
    <style>
        #ViewDialog
        {
            width: 500px;
            height: 300px;
            display: none;
            line-height: 20px;
            position: absolute;
            top: 84px;
            left: 200px;
            z-index: 1002;
            word-wrap: break-word;
            word-break: normal;
            background-color: #ffffff;
        }
        #ClearLogDialog
        {
            width: 500px;
            height: 150px;
            display: none;
            line-height: 20px;
            position: absolute;
            top: 84px;
            left: 200px;
            z-index: 1002;
            word-wrap: break-word;
            word-break: normal;
            background-color: #ffffff;
        }
    </style>
    <script type="text/javascript">
        function ButtonSearch() {
            opts.para["OperationResult"] = $.trim($("#sel_OperationResult").val());
            opts.para["OperationIP"] = $.trim($("#sel_OperationIP").val());
            opts.para["OperationStatus"] = $.trim($("#sel_OperationStatus").val());
            opts.para["OperationUser"] = $.trim($("#sel_OperationUser").val());
            opts.para["TimeFrom"] = $.trim($(".sel_TimeFrom").datebox('getValue'));
            opts.para["TimeTo"] = $.trim($(".sel_TimeTo").datebox('getValue'));
            thisPageNum = 1;
            $("#DataGrid").dg(opts);
        }
        function View(id) {
            $.post("/SysLog/GetItem/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&id=" + id, function (res) {
                jv.SetDivJson($("#ViewDialog"), 4, res);
            });
            $('#ViewDialog').show();
            $('#DIVMask').show();
        }
        function ClearLogDialog() {
            $('#ClearLogDialog').show();
            $('#DIVMask').show();
        }
        function ClearLog() {
            var a = $(".delDate").datebox('getValue');
            if (a == "") {
                alert("请选择删除日期。");
                return;
            }
            var arr = a.split("-");
            var starttime = new Date(arr[0], arr[1], parseInt(arr[2]) + 1);
            var starttimes = starttime.getTime();

            var b = new Date();
            var btimes = new Date(b.getFullYear(), b.getMonth() + 1, b.getDate());
            if (starttimes > btimes.getTime()) {
                alert("删除日期应该小于当前日期。");
                return;
            }
            if (confirm("确定要清空操作日志吗？")) {
                $.post("/SysLog/ClearLog/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&date=" + a, function (res) {
                    if (res == "1") {
                        alert("清除成功!");
                        $('#ClearLogDialog').hide();
                        $('#DIVMask').hide();
                        ButtonSearch()
                    } else if (res == "0")
                        alert("删除失败！");
                    else
                        alert("删除失败！" + res);
                });
            }
        }
        var opts = {
            rows: 15,
            height: 450,
            para: {},
            idField: "Guid",
            url: "/SysLog/SysLogList?dbName=" + encodeURI($.getUrlParam("dbName")),
            columns: [
            { field: 'OperationUser', title: '操作人员', width: 12 },
            { field: 'OperationIP', title: '操作员IP', width: 12 },
            { field: 'OperationAction', title: '操作动作', width: 8, align: 'center' },
            { field: 'OperationStatus', title: '操作结果', width: 8, align: 'center', formatter: function (value, rowData, rowIndex) {
                if (value == 1)
                    return "成功";
                else
                    return "失败";
            }
            },
            { field: 'OperationResult', title: '操作信息', width: 38 },
            { field: 'OperationTime', title: '操作时间', width: 15, align: 'center' },
            { field: 'GUID', title: '查看', width: 8, align: 'center', formatter: function (value, rowData, rowIndex) {
                return "<a onclick='View(\"" + value + "\");' class='grid_a'>查看</a>";
            }
            }
            ]
        };
        $(function () {
            $("#DataGrid").dg(opts); 
        });
    </script>
}
<div style="margin: 5px;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                系统日志搜索
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table class="searchArea" width="100%">
        <tr>
            <td>
                操作人员：
                <input id="sel_OperationUser" type="text" style="width: 150px;" />
                &nbsp;&nbsp;&nbsp;操作IP：&nbsp;&nbsp;&nbsp;
                <input id="sel_OperationIP" type="text" style="width: 145px;" />
                操作结果：
                <select id="sel_OperationStatus">
                    <option value="">请选择</option>
                    <option value="1">成功</option>
                    <option value="0">失败</option>
                </select>
                <br />
                操作信息：
                <input id="sel_OperationResult" type="text" style="width: 150px;" />
                操作时间：从
                <input type="text" style="width: 150px;" class="easyui-datetimebox sel_TimeFrom"
                    onclick="SelectDate('sel_TimeFrom')" />
                <input id="sel_TimeFrom" type="hidden" />
                到
                <input type="text" style="width: 150px;" class="easyui-datetimebox sel_TimeTo" onclick="SelectDate('sel_TimeTo')" />
                <input id="sel_TimeTo" type="hidden" />
                <input type="button" value=" 搜索 " onclick="ButtonSearch()" />
            </td>
        </tr>
    </table>
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/edit.png" />
            </td>
            <td width="300">
                系统日志列表
            </td>
            <td align="right">
                <input type="button" class="button" value="清除日志" onclick="ClearLogDialog();" />
            </td>
        </tr>
    </table>
    <table id="DataGrid" class="pagTable" cellpadding="0" cellspacing="0">
    </table>
    <div>
        <div id="Pagination" class="pagination">
        </div>
        <div id="loading" class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="msg">
    </div>
</div>
<div id="ViewDialog" class="ViewDialog">
    <table class="listTitle">
        <tbody>
            <tr>
                <td width="15">
                    <img src="/images/search.png">
                </td>
                <td width="260">
                    查看系统日志
                </td>
                <td align="right">
                    <input type="button" class="button" value="关闭" onclick="$('#ViewDialog').hide();$('#DIVMask').hide();" />
                </td>
            </tr>
        </tbody>
    </table>
    <div style="width: 488px; height: 245px; padding: 5px; overflow-y: scroll; border: #ccc 1px solid;">
        <b>系统菜单：</b><span id="spa_ParentID"></span><br />
        <b>操作人员：</b><span id="spa_OperationUser"></span><br />
        <b>操作员IP：</b><span id="spa_OperationIP"></span><br />
        <b>操作动作：</b><span id="spa_OperationAction"></span><br />
        <b>操作状态：</b><span id="spa_OperationStatus"></span><br />
        <b>日志信息：</b><span id="spa_OperationResult"></span><br />
        <b>操作时间：</b><span id="spa_OperationTime"></span><br />
    </div>
</div>
<div id="ClearLogDialog" class="ClearLogDialog">
    <table class="listTitle">
        <tbody>
            <tr>
                <td width="15">
                    <img src="/images/search.png">
                </td>
                <td width="260">
                    清除系统日志
                </td>
                <td align="right">
                    <input type="button" class="button" value=" 清除 " onclick="ClearLog()" />
                    <input type="button" class="button" value="关闭" onclick="$('#ClearLogDialog').hide();$('#DIVMask').hide();" />
                </td>
            </tr>
        </tbody>
    </table>
    <div style="width: 488px; height: 100px; padding: 5px; border: #ccc 1px solid;">
        删除日期：<input type="text" style="width: 110px;" class="easyui-datebox delDate" onclick="SelectDate('sel_ClearlogTime')" />
        <input id="sel_ClearlogTime" type="hidden" />之前的记录.
    </div>
</div>
<div id="DIVMask">
</div>
